import { post } from "@/common/request";
import { requestParams, urlApiClientContent } from "@/services/ServerService";
import { text } from "@/common/request";

const personalCenterUrl = urlApiClientContent + 'personalCenter/';
const url = urlApiClientContent + "upgrading/publish/";
const exerciseUrl = urlApiClientContent + "exercise/";
// 能力练测-加入
const joinUrl = urlApiClientContent + "upgrading/join/";
// 
const exchangeUrl = urlApiClientContent + "rights/";

// 上传封面图
export function uploadUpgPracticeImage({ fileName, base64 }) {
  return text(url + requestParams("uploadUpgPracticeImage", { fileName }), {
    base64,
  });
}

//保存练习设置
export function publishPractice(data) {
  return text(url + requestParams("publishPractice", {}), JSON.stringify(data));
}

// 查询练测设置
export function getPracticeSet(upgPracticeUuid) {
  return post(url + requestParams("getPracticeSet", { upgPracticeUuid }), null);
}

// 查询练测统计头部
export function getPracticeCountHeader(data) {
  return post(url + requestParams("getPracticeCountHeader", data), null);
}

// 分页查询每日统计
export function pageUpgPracticeDate(data) {
  return post(url + requestParams("pageUpgPracticeDate", data), null);
}

// 查询练测详情头部
export function getPracticeCheckHeader(data) {
  return post(url + requestParams("getPracticeCheckHeader", data), null);
}

// 分页查询练习统计-学员
export function pageUpgPracticeStudentByDate(data) {
  return post(url + requestParams("pageUpgPracticeStudentByDate", data), null);
}

// 查询学员练测详情头部
export function getPracticeStudentCheckHeader(data) {
  return post(url + requestParams("getPracticeStudentCheckHeader", data), null);
}

// 查询学员练测试题
export function getPracticeStudentCheckItemHistory(data) {
  return post(
    url + requestParams("getPracticeStudentCheckItemHistory", data),
    null
  );
}

// 查询历史创建
export function pageCreateUpgPracticeHistory(data) {
  return post(url + requestParams("pageCreateUpgPracticeHistory", data), null);
}

// 设置是否允许成绩查询
export function setUpgPracticeAllowQueryScore(data) {
  return post(url + requestParams("setUpgPracticeAllowQueryScore", data), null);
}

// 删除练习
export function delUpgPractice(data) {
  return post(url + requestParams("delUpgPractice", data), null);
}

// 是否有人加入练习
export function existStudentJoin(data) {
  return post(url + requestParams("existStudentJoin", data), null);
}

//  查询试题导航
export function getItemNavigationsIm({ practiceUuid }) {
  return post(
    exerciseUrl + requestParams("getItemNavigation", { practiceUuid }),
    null
  );
}

//  查询题型情况-雷达图
export function getMarketItemSituation(data) {
  return post(url + requestParams("getMarketItemSituation", data), null);
}

//  查询分析统计-柱状图
export function getMarketItemStructAnalysis(data) {
  return post(url + requestParams("getMarketItemStructAnalysis", data), null);
}

// 在线练测-统计头部
export function getLcPracticeCountHeader(data) {
  return post(url + requestParams("getLcPracticeCountHeader", data), null);
}

// 在线练测 - 学员
export function pageLcPracticeCountStudent(data) {
  return post(url + requestParams("pageLcPracticeCountStudent", data), null);
}

// 在线练测 - 学员 - 试题
export function listLcPracticeCountStudentItemById(data) {
  return post(
    url + requestParams("listLcPracticeCountStudentItemById", data),
    null
  );
}

// 查询竞赛闯关-成绩统计-关卡列表
export function pageJsPracticeCountLevel(data) {
  return post(url + requestParams("pageJsPracticeCountLevel", data), null);
}

// 查询竞赛闯关-成绩统计-关卡  下的 学员
export function pageJsPracticeCountLevelStudent(data) {
  return post(
    url + requestParams("pageJsPracticeCountLevelStudent", data),
    null
  );
}

// 根据关卡,学员,查询关卡下的答题数据
export function getJsPracticeCountLevelItem(data) {
  return post(url + requestParams("getJsPracticeCountLevelItem", data), null);
}

// 获取下一个学员 - 每日一练/竞赛/有奖
export function getJsPracticeCountStudentNext(data) {
  return post(url + requestParams("getJsPracticeCountStudentNext", data), null);
}

// 查询竞赛闯关-某学员闯过的关卡
export function listJsPracticeStudentLevel(data) {
  return post(url + requestParams("listJsPracticeStudentLevel", data), null);
}

// 根据joinUuid查询答题数据 每日一练/竞赛/有奖
export function getJsPracticeCheckItem(data) {
  return post(url + requestParams("getJsPracticeCheckItem", data), null);
}

// 查询 获奖名单
export function pageUpgPracticeAwardStudent(data) {
  return post(url + requestParams("pageUpgPracticeAwardStudent", data), null);
}

// 获取当前用户人脸识别次数权益
export function getCurrStudentFaceNum() {
  return post(url + requestParams("getCurrStudentFaceNum", {}), null);
}

/**
 * 切屏后重新激活
 */
export async function countLastCutTime() {
  return post(url + requestParams("countLastCutTime", {}), true);
}

/**
 * 查询发布的练习
 */
export async function getPublishExercises(data) {
  return post(joinUrl + requestParams("pageUpgPractice", data), null);
}

// 保存练习用户信息
export function saveUpgPracticeInformationJson(params, data) {
  return text(
    joinUrl + requestParams("saveUpgPracticeInformationJson", params),
    JSON.stringify(data)
  );
}

// 每日一练-组卷
export function composePaper(data) {
  return post(joinUrl + requestParams("composePaper", data), null);
}

// 查询历次练习
export function pageUpgPracticeHistory(data) {
  return post(joinUrl + requestParams("pageUpgPracticeHistory", data), null);
}

// 查询历次练习-每天数据
export function listUpgPracticeDay(data) {
  return post(joinUrl + requestParams("listUpgPracticeDay", data), null);
}

// 历次练习-成绩查询-头部
export function getUpgPracticeScoreResultHeader(data) {
  return post(
    joinUrl + requestParams("getUpgPracticeScoreResultHeader", data),
    null
  );
}

// 历次练习-成绩查询-详情
export function getUpgPracticeScoreResult(data) {
  return post(joinUrl + requestParams("getUpgPracticeScoreResult", data), null);
}

// 历次练习-成绩查询-试题
export function listUpgPracticeScoreResultItem(data) {
  return post(
    joinUrl + requestParams("listUpgPracticeScoreResultItem", data),
    null
  );
}

// 练习端-交卷后-综合分析
export function getComprehensiveAnalysis(data) {
  return post(joinUrl + requestParams("getComprehensiveAnalysis", data), null);
}

// 历史-成绩查询-在线练测-试题
export function listUpgPracticeScoreResultItemByPracticeUuid(data) {
  return post(
    joinUrl +
    requestParams("listUpgPracticeScoreResultItemByPracticeUuid", data),
    null
  );
}

// 切屏记录
export function recordCutTimes(data) {
  return post(joinUrl + requestParams("recordCutTimes", data), null);
}

// 保存签名
export function upgPracticeSign(params, data) {
  return text(
    joinUrl + requestParams("upgPracticeSign", params),
    JSON.stringify(data)
  );
}

// 人脸识别是否通过
export function faceRecognition(params, data) {
  return text(
    joinUrl + requestParams("faceRecognition", params),
    JSON.stringify(data)
  );
}

// 知识竞赛闯关，每次交卷后，根据 bhCheckUuid 查询，是否可以下一步
export function getUpgKnowledgeStatus(data) {
  return post(joinUrl + requestParams("getUpgKnowledgeStatus", data), null);
}

// 知识竞赛闯关后 - 继续/重新 闯关
export function doUpgKnowledgeNext(data) {
  return text(
    joinUrl + requestParams("doUpgKnowledgeNext", {}),
    JSON.stringify(data)
  );
}

// 查询我的练习获奖记录
export function getUpgPracticeAwardData(data) {
  return post(joinUrl + requestParams("getUpgPracticeAwardData", data), null);
}

// 兑换发送验证码
export function sendAwardCode(data) {
  return post(joinUrl + requestParams("sendAwardCode", data), null);
}

// 提交兑换
export function doAwardExchange(params, data) {
  return text(
    joinUrl + requestParams("doAwardExchange", params),
    JSON.stringify(data)
  );
}

// 获取省市区
export function getCityData() {
  return post(joinUrl + requestParams("getProvinceData", {}), null);
}

// 查询所属机构
export function getOrganList() {
  return post(personalCenterUrl + requestParams('getOrganList', {}), null);
}

// 新增权益
export function submitExchange(data) {
  return post(exchangeUrl + requestParams('add', data), null);
}

// 获取兑换明细
export function getExchangeInfo(data) {
  return post(exchangeUrl + requestParams('exchangeInfo', data), null);
}